package com.xyy.saas.payment.dao.mapper;

import com.xyy.saas.payment.dao.model.RefundOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @author wangtianqi
 */
@Mapper
public interface RefundOrderMapper {
    int deleteByPrimaryKey(Long id);

    int insert(RefundOrder record);

    int insertSelective(RefundOrder record);

    RefundOrder selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(RefundOrder record);

    int updateByPrimaryKey(RefundOrder record);

    List<RefundOrder> selectListByPayNo(String payNo);

    List<RefundOrder> selectNoneRoyaltyRefundOrders(@Param("beginTime") LocalDateTime beginTime, @Param("endTime")LocalDateTime endTime);

    Integer queryTotalRefundAmount(@Param("payNo")String payNo);

    RefundOrder selectByRefundNo(String refundNo);

    List<RefundOrder> selectByChannelChargeNo(@Param("channelChargeNo") String channelChargeNo,@Param("channel") String channel);

    RefundOrder selectByChannelRefundNo(@Param("payNo") String payNo, @Param("channelRefundNo") String channelRefundNo);

    RefundOrder selectByChannelRefundNo2(@Param("channelRefundNo") String channelRefundNo);

    List<RefundOrder> selectListByStatus(@Param("createTime") Date createTime, @Param("status")Byte status, @Param("pageOffset")Integer pageOffset, @Param("pageSize")Integer pageSize);

    List<RefundOrder> selectListByStatusAndPayChannel(@Param("payChannel")String payChannel, @Param("status")Byte status, @Param("pageOffset")Integer pageOffset, @Param("pageSize")Integer pageSize);

    List<RefundOrder> queryPinganCreditListByTime(@Param("beginTime") LocalDateTime beginTime, @Param("endTime")LocalDateTime endTime);

    Integer selectCountByStatus(@Param("createTime") Date createTime, @Param("status")Byte status);

    int updateStatusByRefundNo(@Param("refundNo") String refundNo,@Param("channelRefundNo") String channelRefundNo, @Param("successTime") Date successTime,@Param("updateTime") Date updateTime, @Param("status")Byte status, @Param("channelTransactionNo") String channelTransactionNo, @Param("version")Integer version);

    RefundOrder selectByBusinessRefundNo(@Param("payNo") String payNo, @Param("businessRefundNo") String businessRefundNo);

    RefundOrder selectByBusinessRefundNo2(@Param("businessRefundNo") String businessRefundNo);

    List<RefundOrder> selectRefundOrderListByCondition(@Param("payNo") String payNo, @Param("businessOrderType")String businessOrderType,
                                                             @Param("payer") String payer,  @Param("channelTransactionNo")String channelTransactionNo,
                                                             @Param("channel") String channel,
                                                             @Param("beginTime") Date beginTime, @Param("endTime") Date endTime,
                                                             @Param("page")int page,  @Param("pageSize")int pageSize);

    int selectRefundOrderCountByCondition(@Param("payNo") String payNo, @Param("businessOrderType")String businessOrderType,
                                                       @Param("payer") String payer,  @Param("channelTransactionNo")String channelTransactionNo,
                                                       @Param("channel") String channel,
                                                       @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);

    RefundOrder countAmountByUserId(@Param("userId") String userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<RefundOrder> queryRefundOrderSingleSide1(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime,
                                                  @Param("payChannels") List<String> payChannels, @Param("tradeCodes") List<Integer> tradeCodes,
                                                  @Param("excludeAccountIds") List<String> tradeCheckExcludeAccountIds);


    List<RefundOrder> queryRefundOrderSingleSide2(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime,
                                                  @Param("payChannels") List<String> payChannels, @Param("tradeCodes") List<Integer> tradeCodes,
                                                  @Param("excludeAccountIds") List<String> tradeCheckExcludeAccountIds);

    List<RefundOrder> findJdChannelSingleSideTrade(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);

    List<RefundOrder> selectByRefundNos(List<String> refundNos);

}